##=============================================================================
## Main Manuscript: Table 2
##=============================================================================

##-----------------
# clear environment
rm(list=ls())
options(stringsAsFactors = FALSE, scipen = 999)
# source("R/functions.R")

##--------
# Set seed
seed <- sample.int(.Machine$integer.max, 1)
set.seed(seed)

##-------------
# Load Packages
ipak <- function(pkg){new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if(length(new.pkg)) install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}

packages <- c("tidyverse")

ipak(packages)

##---------
# Load data
#setwd("/Users/austinknuppe/Library/CloudStorage/Dropbox/Ukraine2022WartimeSurvey/Paper_peace/final_version_oct_2024/replication-scripts")
load("clean_ukraine_data.RData")

##-------------------------------------------
# Descriptive Stats for Independent Variables
dat %>% 
  dplyr::select(wave, survival_mindset, frontline_b, ln_viina_two_months,
                per_idx_invcov, fam_idx_invcov) %>% 
  group_by(wave) %>% 
  summarise(across(everything(), list(mean = mean, sd = sd), na.rm = TRUE)) %>% 
  pivot_longer(cols = -wave, names_to = "variable", values_to = "stat")

dat %>% 
  dplyr::select(wave, survival_mindset, frontline_b, ln_viina_two_months,
                per_idx_invcov, fam_idx_invcov) %>% 
  group_by(wave) %>% 
  summarise_all(~ sum(is.na(.))) %>% 
  pivot_longer(cols = -wave, names_to = "variable", values_to = "missing")

rm(list = ls())
##=============================================================================
## End of File
##=============================================================================